<template>
  <div>
    <div class="user-opt">
      <div>
        <h1>我的食谱</h1>
      </div>
      <el-button v-if="isMe">发布食谱</el-button>
    </div>
    <div class="list-box">
      <div class="empty-status-box" v-if="list.length == 0">
        <span v-if="isMe">
          你还没有任何食谱哦~，快去<span
            class="link-btn"
            @click="$router.push('/publish')"
            >发布</span
          >一篇吧！
        </span>
        <span v-else> 该用户没有任何公开的菜单，快去别处看看吧~ </span>
      </div>
      <div
        class="list-node"
        v-for="(item, i) in list"
        :key="i"
        @click="$router.push('/shipu/1')"
      >
        <shipu-type-list :id="item"></shipu-type-list>
        <el-dropdown class="opts" v-if="isMe">
          <!-- <span class="link-btn" style="padding: 0 1.25rem">
              {{ userInfo.username }}
              <i class="el-icon-arrow-down el-icon--right"></i>
            </span> -->
          <a-icon type="more" />
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item @click.native="setStatusOpt(i)">{{
              getStatusOptStr(item)
            }}</el-dropdown-item>
            <el-dropdown-item @click.native="del(i)">删除</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
    </div>
    <el-button class="show-more-btn" v-if="more && list.length > 4">加载更多</el-button>
  </div>
</template>

<script>
import ShipuTypeList from "../ShipuShowType/ShipuTypeList.vue";
export default {
  components: { ShipuTypeList },
  props: {
    isMe: {
      type: Boolean,
      default: true,
    },
  },
  data() {
    return {
      list: [1, 2, 3, 4, 5],
      more:true,
    };
  },
  methods: {
    getStatusOptStr(id) {
      if (id == 1) return "设置为仅自己可见";
      return "设置为全部用户可见";
    },
    setStatusOpt(id) {
      //todo 取反
      this.$msg.success("设置成功");
    },
    del(i) {
      this.list.splice(i, 1);
      this.$msg.success("删除成功");
    },
  },
};
</script>

<style lang="less" scoped>
.user-opt {
  display: flex;
  justify-content: space-between;
}
.list-box {
  width: 100%;
  .list-node {
    margin: 10px 0;
    position: relative;
    .opts {
      position: absolute;
      top: 10px;
      right: 10px;
      font-size: 25px;
    }
  }
}
.show-more-btn {
  width: 100%;
}
.empty-status-box {
  height: 200px;
  line-height: 200px;
  text-align: center;
}
</style>

